package com.leonardo.persistenceme.model.persistancehandlers;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public class FloatPersistenceHandler extends PersistenceHandler {

	public void persist(Object obj, DataOutputStream stream) throws IOException {
		if(obj == null) {
			stream.writeFloat(Float.MIN_VALUE);
			return;
		}
		Float value = (Float) obj;
		stream.writeFloat(value.floatValue());
	}

	public Object recover(DataInputStream stream) throws IOException {
		float value = stream.readFloat();
		if(value == Float.MIN_VALUE)
			return null;
		return new Float(value);
	}

}
